SuperStrict

Framework BRL.StandardIO

Import "parser.bmx"

Local syntax:String[] = ["\pL+", "\s+", "~q[^~q]*~q", "="]
Local grammar:Int[][] = [[TParser.RULE_START, 0, 3, 2], [TParser.RULE_SKIP, 1]]

Local p:TParser = TParser.Create(syntax, grammar)

Local c:TCstNode = p.ParseStream( ReadStream("test.txt") )

c.Visit New TLister

Type TLister Extends TCstVisitor
	
	Field _t:String
	
	Method InNonTerm(n:TCstNonTerm)
		Print _t + n.GetType() + " {"
		_t :+ "~t"
	End Method
	
	Method InTerm(t:TToken)
		Print _t + t.ToString()
	End Method
	
	Method OutNonTerm(n:TCstNonTerm)
		_t = _t[1..]
		Print _t + "}"
	End Method
	
End Type
